package cn.angis.system.dto.output;

import cn.angis.db.model.DtoOutput;
import cn.angis.system.model.Role;
import lombok.Getter;
import lombok.Setter;
import org.beetl.sql.annotation.entity.Column;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 登录使用
 *
 * @Author：chow
 * @Date: 2023-01-05
 */
@Getter
@Setter
public class LoginOutput extends DtoOutput {
    /**
     * 用户id
     */
    private String id;

    /**
     * 部门id
     */
    private String deptId;
    /**
     * 用户名
     */
    private String username;
    /**
     * 用户昵称
     */
    private String nickName;
    /**
     * 用户类型（0、管理员；1、普通用户）
     */
    private String userType;
    /**
     * 用户邮箱
     */
    private String email;
    /**
     * 手机号码
     */
    private String phoneNumber;
    /**
     * 性别（0、男；1、女）
     */
    private String sex;
    /**
     * 头像
     */
    private String avatarUrl;
    /**
     * 帐号状态（0、正常；1、禁用）
     */
    private String userStatus;
    /**
     * 资源信息
     */
    private List<String> resources;
    /**
     * 部门名称
     */
    private String deptName;
    /**
     * 角色名称
     */
    private String roleName;

    public String token;

    private String remark;
    private List<String> postIds;
    private List<String> roleIds;
    private List<Role> roles;
    private String phone;

    private Date lastLoginTime;
    private Date expireTime;
    private String ip;
    private String loginLocation;
    private String browser;
    private String os;
    private Long lastLoginTimeLong;
    private Long expireTimeLong;

    public Date getLastLoginTime() {
        return lastLoginTimeLong!=null ?  new Date(lastLoginTimeLong) : lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        if (lastLoginTime!=null) {
            this.lastLoginTimeLong = lastLoginTime.getTime();
        }
        this.lastLoginTime = lastLoginTime;
    }

    public Date getExpireTime() {
        return expireTimeLong!=null ?  new Date(expireTimeLong) : expireTime;
    }

    public void setExpireTime(Date expireTime) {
        if (expireTime!=null) {
            this.expireTimeLong = expireTime.getTime();
        }
        this.expireTime = expireTime;
    }
}
